//
//  UserModelManager.m
//  OnionHome
//
//  Created by fengjie on 2019/9/18.
//  Copyright © 2019 FengJie. All rights reserved.
//

#import "UserModelManager.h"

@implementation UserModelManager
#pragma mark 退出登录
+(void)loginout{
    kAppDelegate.tabBarController = nil;
    kRootViewController = nil;
    kRootViewController = [[BasseNavigationController alloc] initWithRootViewController:[LoginViewController new]];
    [self saveLoginType:NO];
}

/**
 登录切换根视图
 */
+(void)goToLogin{
    [UserModelManager saveLoginType:YES];
    kRootViewController = kAppDelegate.tabBarController;
}
/**保存登录状态*/
+(void)saveLoginType:(BOOL)isLogin{
    [[NSUserDefaults standardUserDefaults] setBool:isLogin forKey:@"isLogin"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
/**获取登录状态*/
+(BOOL)getLoginType{
    NSNumber *showTutorial = [[NSUserDefaults standardUserDefaults] objectForKey:@"isLogin"];
    BOOL isLogin = NO;
    if(!showTutorial){
        isLogin = NO;
    }else{
        isLogin = [showTutorial boolValue];
    }
     return isLogin;
}


/// 引导页进入后设置为yes
+(void)setGuideType{
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"user_has_onboarded"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}
/// 获取是否需要显示引导页
+(BOOL)getGuideType{
    NSNumber *showGuide = [[NSUserDefaults standardUserDefaults] objectForKey:@"user_has_onboarded"];
    BOOL isGuide = NO;
    if(showGuide){
        isGuide = [showGuide boolValue];
    }
     return showGuide;
}
@end
